$(document)
		.ready(
				function() {

					$
							.ajax({
								type : "post",
								url : "articleList",
								async : true,
								dataType : 'json',
								success : function(data) {
									
									console.log(data)
									var list = data.listVo;// 文章数组
									for (var i = 0; i < list.length; i++) {
										var id = list[i].id;
										var type = list[i].type;// 类型
										var title = list[i].title;// 标题
								
										var date = list[i].date;// 发布时间
										var startDate = list[i].startDate;// 活动开始时间
										var endDate = list[i].endDate;// 活动结束时间
										var address = list[i].address;// 地址
										var joinUserNum = list[i].joinUserNum;// 参加人数int
									
									

										if (type == 'yule') {
											type = '娱乐：'
										}
										if (type == 'xueshu') {
											type = '学术：'
										}
										if (type == 'jingsai') {
											type = '竞赛：'
										}
										if (type == 'shetuan') {
											type = '社团：'
										}
										if (type == 'qita') {
											type = '其他：'
										}
										
										var reg=new RegExp("-","g");
										endDate1 = endDate.replace(reg,'');// 活动结束时间
										startDate1=startDate.replace(reg,'');// 开始时间
										newdate1 = data.newdate.replace(reg,'');// 当前时间
										var articleboff;
										// 活动开始时间
										if (endDate1 > newdate1) {
											articleboff = '<span>报名中</span>';
										
										} else {
											articleboff = '<span class="hd_tag_js">已截止</span>';
										
										}
										if (endDate1 >= newdate1 && startDate1<= newdate1) {
											articleboff = '<span class="hd_tag_jh">进行中</span>';
								
										}

										var newstartDate = startDate.substring(
												10, 5).replace("-", "月")
												+ '日';// 报名开放日期
										var newendDate = endDate.substring(10,
												5).replace("-", "月")
												+ '日';// 报名结束日期

										var newstartDateSSS = startDate
												.slice(11);// 报名开放时间 12:30
										var newendDateSSS = endDate.slice(11);// 报名结束时间
																				// 20:30

										var playDate = newendDate + ' '
												+ newstartDateSSS + '-'
												+ newendDateSSS;
										var joinUserhtml='';
										var joinUser=list[i].joinUser;
										for(var j = 0; j < joinUser.length; j++){
											if(joinUser[j].id==data.userid){
												joinUserhtml='<div class="pet_topci_video" style="background-color: limegreen;"><span>已参加</span></div>';
											}
										} 
										
										$("#articel-List")
												.append(
														'<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-right pet_hd_list">'
																+joinUserhtml	
																+ ' <a href="articleOne?id='
																+ id
																+ '" class="pet_hd_block"> <div class="pet_hd_block_title">'
																+ title
																+ '</div> <div class="pet_hd_block_map"> <i class="iconfont">'
																+ type
																+ '</i>'
																+ address
																+ '</div>	<div class="pet_hd_block_tag">'
																+ articleboff
																+ '  '
																+ playDate
																+ '</div>	</a>	</li>');

									}

									if(data.userid==-1){
										$('#head-user').html('<div class="am-header-left am-header-nav "><a href="index" class="iconfont pet_head_jt_ico"><img src="myAssets/img/返回.png"></a></div> <div class="pet_news_list_tag_name">！未登录 , 无法发布</div>');
									}
								},
								error : function() {
								}
							});

				})

// 获取当前时间方法
function CurentTime() {
	var now = new Date();
	var year = now.getFullYear(); // 年
	var month = now.getMonth() + 1; // 月
	var day = now.getDate(); // 日
	var hh = now.getHours(); // 时
	var mm = now.getMinutes(); // 分
	var clock = year + "-";
	if (month < 10)
		clock += "0";
	clock += month + "-";
	if (day < 10)
		clock += "0";
	clock += day + " ";
	if (hh < 10)
		clock += "0";
	clock += hh + ":";
	if (mm < 10)
		clock += '0';
	clock += mm;
	return (clock);
}
